package org.dualr.litelog.servlet;

import java.io.IOException;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.dualr.litelog.dao.PostDao;
import org.dualr.litelog.entity.Post;
import org.dualr.litelog.utils.LiteLogUtil;

@SuppressWarnings("serial")
public class SitemapServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@SuppressWarnings("static-access")
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		List<Post> postList = PostDao.getInstance().getInstance().getPostByRange(0,499);
		Date todaytime = new Date();
		String date = LiteLogUtil.getInstance().formateDate(todaytime, "yyyy-MM-dd");
		req.setAttribute("PostList", postList);
		req.setAttribute("date", date);
		try {
			req.getRequestDispatcher("sitemap.jsp").forward(req, resp);
		} catch (ServletException e) {
			e.printStackTrace();
		}
	}
}
